{extend name="layout" /}
{block name="content"}
<div class="mui-content">
	<div class="uk-margin-small-top controll-atav-1">
		<form method="post" id="formid">
		<ul class="mui-table-view max">
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">成交客户</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<span class="tm-font-gray">{$info.name}</span>
								<input type="hidden" name="clientid" value="{$info.id}">
							</div>
							<div class="tm-icon">
								<img src="{$images_path}xinxin.png" alt="" width="6" height="6" />
							</div>
						</div>
					</div>
				</div>
			</li>
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">单号</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<span class="tm-font-gray">自动生成</span>
							</div>
						</div>
					</div>
				</div>
			</li>
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">线索分类</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<select name="kind" style="height: 30px;padding: 2px;margin-right: 25px;padding-left: 100px;">
									<option value="">请选择</option>
									{volist name=":config('CLIENT_KIND')" id="v"}
									<option value="{$key}" {eq name="key" value="$info.kind"} selected {/eq}>{$v}</option>
									{/volist}
								</select>
							</div>
							<div class="tm-icon">
								<img src="{$images_path}xinxin.png" alt="" width="6" height="6"/>
							</div>
						</div>
					</div>
				</div>
			</li>
			{eq name="info.kind" value="gouche"}
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="">
							<span class="tm-font-bold">购买车型</span>
						</div>
						<div class="tm-icon-item" style="width: 45%;margin-left: 36%;">
							<!-- <div class="tm-icon-label" style="margin-left: -25%;margin-right: -28%;">
								<select name="cartypeid1" style="width: 70px;height: 30px;padding: 2px;" onchange="get_cartype(this, this.value)">
									<option value="">请选择</option>
									{volist name=":get_model_func('Cartype', 'list_datad', ['pid'=>0, 'hide'=>0], 1, 300, 'id,title', 'listorder asc,id asc')" id="v"}
									<option value="{$v.id}" {eq name="info.cartypeid1" value="$v.id"} selected {/eq}>{$v.title}</option>
									{/volist}
								</select>
								<select name="cartypeid2" style="width: 70px;height: 30px;padding: 2px;" onchange="get_cartype(this, this.value)">
									{volist name=":get_model_func('Cartype', 'list_datad', ['pid'=>$info.cartypeid1, 'hide'=>0], 1, 300, 'id,title', 'listorder asc,id asc')" id="v"}
									<option value="{$v.id}" {eq name="info.cartypeid2" value="$v.id"} selected {/eq}>{$v.title}</option>
									{/volist}
								</select>
								<select name="cartypeid3" style="width: 70px;height: 30px;padding: 2px;" onchange="get_car(this, this.value)">
									{volist name=":get_model_func('Cartype', 'list_datad', ['pid'=>$info.cartypeid2, 'hide'=>0], 1, 300, 'id,title', 'listorder asc,id asc')" id="v"}
									<option value="{$v.id}" {eq name="info.cartypeid3" value="$v.id"} selected {/eq}>{$v.title}</option>
									{/volist}
								</select>
								<select name="carid" style="width: 75px;height: 30px;padding: 2px;">
									{volist name=":get_model_func('Car', 'list_datad', ['pid'=>$info.cartypeid3, 'hide'=>0], 1, 300, 'id,title', 'id asc')" id="v"}
									<option value="{$v.id}" {eq name="info.carid" value="$v.id"} selected {/eq}>{$v.title}</option>
									{/volist}
								</select>
								<div class="tm-icon" style="float: right;margin-top: 4%;margin-right: -3px;">
									<img src="{$images_path}xinxin.png" alt="" width="6" height="6"/>
								</div>
							</div> -->	
							<div class="tm-icon-label" style="width: 100%;">
								<select name="cartypeid1" style="width: 30%;height: 30px;padding: 2px;" onchange="get_cartype(this, this.value)">
									<option value="">请选择</option>
									<!-- {volist name=":get_model_func('Cartype', 'list_datad', ['pid'=>0, 'hide'=>0], 1, 300, 'id,title', 'listorder asc,id asc')" id="v"} -->
									{volist name=":get_model_func('Cartype', 'list_datad', ['id'=>157])" id="v"}
									<option value="{$v.id}">{$v.title}</option>
									{/volist}
								</select>
								<select name="cartypeid2" style="width: 50%;height: 30px;padding: 2px;" onchange="get_car(this, this.value)">
									<option value="">请选择</option>
								</select>
								<!-- <select name="cartypeid3" style="width: 70px;height: 30px;padding: 2px;" onchange="get_car(this, this.value)">
									<option value="">请选择</option>
								</select>
								<select name="carid" style="width: 75px;height: 30px;padding: 2px;">
									<option value="">请选择</option>
								</select> -->
								<div class="tm-icon" style="float: right;margin-top: 5%;margin-right: -8.5%;">
									<img src="{$images_path}xinxin.png" alt="" width="6" height="6"/>
								</div>
							</div>			
						</div>
					</div>
				</div>
			</li>
			{/eq}
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">数量</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<input type="text" name="nums" value="1" style="height: 30px;width: 60%;float: right;text-align: right;border: none;">
							</div>
							<div class="tm-icon">
								<img src="{$images_path}xinxin.png" alt="" width="6" height="6" />
							</div>
						</div>
					</div>
				</div>
			</li>
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">成交总额</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<input type="text" name="totalprice" value="" style="height: 30px;width: 60%;float: right;text-align: right;border: none;">
							</div>
							<div class="tm-icon">
								<img src="{$images_path}xinxin.png" alt="" width="6" height="6" />
							</div>
						</div>
					</div>
				</div>
			</li>
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">录入时间</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<!-- <span class="tm-font-gray"></span> -->
								<input class="tm-font-gray" type="date" name="sucdate" value="" style="width: 120px;height: 30px;border: none;margin-right: -30px;">
							</div>
							<div class="tm-icon">
								<img src="{$images_path}xinxin.png" alt="" width="6" height="6" />
							</div>
						</div>
					</div>
				</div>
			</li>

			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">付款方式</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<!-- <span class="tm-font-gray"></span> -->
								<select name="paytype" style="height: 30px;padding: 2px;margin-right: 25px;padding-left: 100px;">
									<option value="">请选择</option>
									{volist name=":config('PAYTYPE')" id="v"}
									<option value="{$key}" {eq name="key" value="4"} selected {/eq}>{$v}</option>
									{/volist}
								</select>
							</div>
						</div>
					</div>
				</div>
			</li>
			<li class="mui-table-view-cell">
				<a class="mui-navigate-right upload_file" href="javascript:" coco_upload ajax-url="/v2/accessory/upload_acce"  ajax-callback="coco_suc" ajax-data="{}">
					<div class="tm-cell-pad">
						<div class="tm-flex">
							<div class="tm-flex-head tm-flex-1">
								<span class="tm-font-bold">图片上传</span>
							</div>
							<div class="tm-flex" id="images">
							</div>
						</div>
					</div>
				</a>
			</li>
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">付款状态</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<!-- <span class="tm-font-gray"></span> -->
								<select name="status" style="height: 30px;padding: 2px;margin-right: 20px;padding-left: 100px;">
									<option value="">请选择</option>
									{volist name=":config('PAY_STATUS')" id="v"}
									<option value="{$key}" {eq name="key" value="1"} selected {/eq}>{$v}</option>
									{/volist}
								</select>
							</div>
						</div>
					</div>
				</div>
			</li>

			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">备注</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<!-- <span class="tm-font-gray"></span> -->
								<input type="text" name="remark" value="" style="float:right;margin-right: 20px; width: 120%;height: 30px;border: none;text-align: right;padding: 0px;">
							</div>
						</div>
					</div>
				</div>
			</li>
		</ul>
		<ul class="mui-table-view max uk-margin-small-top">
			<li class="mui-table-view-cell">
				<div class="tm-cell-pad">
					<div class="tm-flex flex-align-center">
						<div class="tm-flex-1">
							<span class="tm-font-bold">所属经纪人</span>
						</div>
						<div class="tm-icon-item">
							<div class="tm-icon-label">
								<span class="tm-font-gray">{$info.realname}</span>
								<input type="hidden" name="userid" value="{$info.userid}">
								<input type="hidden" name="brokerid" value="{$info.brokerid}">
							</div>
						</div>
					</div>
				</div>
			</li>
		</ul>
		</form>
		<div class="uk-margin-large-top uk-text-center">
            <button class="mui-btn mui-btn-green btn-radiu-large pay-btn cocoPostFormAjax" formid="formid" ajaxurl="{:url('v2/client/order_add')}" type="button" style="margin-top: -20px;width: 90%; height: 45px;" ajax-callback="suc_back">
                保存
            </button>
        </div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
	function coco_suc(obj, data) {
		if (data == '') {
			return false;
		}
		var html = '<div class="tm-atav tm-flex-head"><div class="tm-location-parent"><div class="tm-location-img" style="background-image: url('+data.url+');"></div><img class="redundant-img" src="{$images_path}px-1.png" alt="" width="100"></div><input type="hidden" value="'+data.id+'" name="acce[]" /></div>';
		$("#images").append(html);
	}
	function get_cartype(obj, pid) {
		$.post("{:url('v2/index/get_cartype')}", {pid: pid}, function(datajson) {
			var data = datajson.response;
			if (!data) {
				return false;
			}
			var html = '<option value="">请选择</option>';
			$.each(data, function(index, item) {
				html += '<option value="'+item.id+'">'+item.title+'</option>';
			});
			$(obj).next().html('');
			$(obj).next().append(html);
		});
	}
	function get_car(obj, pid) {
		$.post("{:url('v2/index/get_car')}", {pid: pid}, function(datajson) {
			var data = datajson.response;
			if (!data) {
				return false;
			}
			var html = '<option value="">请选择</option>';
			$.each(data, function(index, item) {
				html += '<option value="'+item.id+'">'+item.title+'</option>';
			});
			$(obj).next().html('');
			$(obj).next().append(html);
		});
	}
	function suc_back(obj, data) {
   		coco_msg('保存成功');
		setTimeout(function() {
			wx.miniProgram.navigateBack();
		}, 500);
   }
</script>
{/block}